package com.after.saas.file.handler;

import com.after.saas.file.constants.MedalLevelEnum;
import com.after.saas.file.constants.MedalTitleEnum;
import com.after.saas.file.service.MedalRecordService;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @Description
 * @Classname MedalHandler
 * @Author hjchen
 * @Version V1.0.0
 * @Since 1.0
 * @Date 2023/4/7 14:12
 */

@Component
public class BronzeHandler extends MedalHandler {

    private final MedalRecordService medalRecordService;

    public BronzeHandler(MedalRecordService medalRecordService) {
        this.medalRecordService = medalRecordService;
    }

    @Override
    public MedalTitleEnum getMedalEnum() {
        return MedalTitleEnum.BRONZE;
    }

    /**
     * 计算积分
     *
     * @param
     * @return void
     * @author hjchen
     * @date 2023/4/7 14:14
     **/
    @Override
    public MedalRecord saveMedalRecord(BigDecimal sumPoints) {
        return medalRecordService.saveUpdate(buildMedalRecord(sumPoints));
    }

    @Override
    public void intiLevelMap() {
        levelMap.put(MedalLevelEnum.LV1.name(), "20");
        levelMap.put(MedalLevelEnum.LV2.name(), "40");
        levelMap.put(MedalLevelEnum.LV3.name(), "60");
        levelMap.put(MedalLevelEnum.LV4.name(), "80");
        levelMap.put(MedalLevelEnum.LV5.name(), "100");
    }

}
